<template>
  <div class="app-container">
    <el-table
      v-loading="loading"
      :data="carList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="${comment}" align="center" prop="id" />
      <el-table-column label="车辆所在城市" align="center" prop="address" />
      <el-table-column label="车辆号牌" align="center" prop="vehicleNo" />
      <el-table-column label="车牌颜色" align="center" prop="plateColor" />
      <el-table-column label="核定载客位" align="center" prop="seats" />
      <el-table-column label="车辆厂牌" align="center" prop="brand" />
      <el-table-column label="车辆型号" align="center" prop="model" />
      <el-table-column label="车辆类型" align="center" prop="vehicleType" />
      <el-table-column label="车辆所有人" align="center" prop="ownerName" />
      <el-table-column label="车辆颜色" align="center" prop="vehicleColor" />
      <el-table-column label="发动机号" align="center" prop="engineId" />
      <el-table-column label="${comment}" align="center" prop="vin" />
      <el-table-column
        label="车辆注册日期"
        align="center"
        prop="certifyDateA"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.certifyDateA, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="燃料类型(1：汽油，2：柴油，3：天然气，4：液化气，5：电动，9：其他）"
        align="center"
        prop="fueType"
      />
      <el-table-column
        label="发动机排量"
        align="center"
        prop="engineDisplace"
      />
      <el-table-column
        label="车辆运输证发证机构"
        align="center"
        prop="transAgency"
      />
      <el-table-column label="车辆经验区域" align="center" prop="transArea" />
      <el-table-column
        label="车辆运输证有效期起"
        align="center"
        prop="transDateStart"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.transDateStart, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="车辆运输证有效期止"
        align="center"
        prop="transDateEnd"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.transDateEnd, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="车辆初次登记日期"
        align="center"
        prop="certifyDateB"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.certifyDateB, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="车辆的检修状态(0：未检修，1：已检修，2：未知）"
        align="center"
        prop="fixState"
      />
      <el-table-column
        label="下次年检时间"
        align="center"
        prop="nextFixDate"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.nextFixDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="年度审验状态" align="center" prop="checkState" />
      <el-table-column
        label="发票打印设备序列号"
        align="center"
        prop="feePrintId"
      />
      <el-table-column
        label="卫星定位装置品牌"
        align="center"
        prop="gpsBrand"
      />
      <el-table-column label="卫星型号" align="center" prop="gpsModel" />
      <el-table-column
        label="卫星定位设备安装日期"
        align="center"
        prop="gpsInstallDate"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gpsInstallDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="报备日期"
        align="center"
        prop="registerDate"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.registerDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="服务类型：1：网络预约出租车，2：巡游出租车，3：私人小客车合乘"
        align="center"
        prop="commercialType"
      />
      <el-table-column
        label="运价编码 关联计价规则"
        align="center"
        prop="fareType"
      />
      <el-table-column
        label="状态：0:有效，1：失效"
        align="center"
        prop="state"
      />
      <el-table-column label="终端Id" align="center" prop="tid" />
      <el-table-column label="轨迹ID" align="center" prop="trid" />
      <el-table-column label="轨迹名称" align="center" prop="trname" />
      <el-table-column
        label="创建时间"
        align="center"
        prop="gmtCreate"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gmtCreate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="修改时间"
        align="center"
        prop="gmtModified"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gmtModified, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:user:edit']"
            >查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1000px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="200px">
        <el-form-item label="车辆所在城市" prop="address">
          <el-input v-model="form.address" placeholder="请输入车辆所在城市" />
        </el-form-item>
        <el-form-item label="车辆号牌" prop="vehicleNo">
          <el-input v-model="form.vehicleNo" placeholder="请输入车辆号牌" />
        </el-form-item>
        <el-form-item label="车牌颜色" prop="plateColor">
          <el-input v-model="form.plateColor" placeholder="请输入车牌颜色" />
        </el-form-item>
        <el-form-item label="核定载客位" prop="seats">
          <el-input v-model="form.seats" placeholder="请输入核定载客位" />
        </el-form-item>
        <el-form-item label="车辆厂牌" prop="brand">
          <el-input v-model="form.brand" placeholder="请输入车辆厂牌" />
        </el-form-item>
        <el-form-item label="车辆型号" prop="model">
          <el-input v-model="form.model" placeholder="请输入车辆型号" />
        </el-form-item>
        <el-form-item label="车辆所有人" prop="ownerName">
          <el-input v-model="form.ownerName" placeholder="请输入车辆所有人" />
        </el-form-item>
        <el-form-item label="车辆颜色" prop="vehicleColor">
          <el-input v-model="form.vehicleColor" placeholder="请输入车辆颜色" />
        </el-form-item>
        <el-form-item label="发动机号" prop="engineId">
          <el-input v-model="form.engineId" placeholder="请输入发动机号" />
        </el-form-item>
        <el-form-item label="${comment}" prop="vin">
          <el-input v-model="form.vin" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="车辆注册日期" prop="certifyDateA">
          <el-date-picker
            clearable
            v-model="form.certifyDateA"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择车辆注册日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="发动机排量" prop="engineDisplace">
          <el-input
            v-model="form.engineDisplace"
            placeholder="请输入发动机排量"
          />
        </el-form-item>
        <el-form-item label="车辆运输证发证机构" prop="transAgency">
          <el-input
            v-model="form.transAgency"
            placeholder="请输入车辆运输证发证机构"
          />
        </el-form-item>
        <el-form-item label="车辆经验区域" prop="transArea">
          <el-input v-model="form.transArea" placeholder="请输入车辆经验区域" />
        </el-form-item>
        <el-form-item label="车辆运输证有效期起" prop="transDateStart">
          <el-date-picker
            clearable
            v-model="form.transDateStart"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择车辆运输证有效期起"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="车辆运输证有效期止" prop="transDateEnd">
          <el-date-picker
            clearable
            v-model="form.transDateEnd"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择车辆运输证有效期止"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="车辆初次登记日期" prop="certifyDateB">
          <el-date-picker
            clearable
            v-model="form.certifyDateB"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择车辆初次登记日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="车辆的检修状态(0：未检修，1：已检修，2：未知）"
          prop="fixState"
        >
          <el-input
            v-model="form.fixState"
            placeholder="请输入车辆的检修状态(0：未检修，1：已检修，2：未知）"
          />
        </el-form-item>
        <el-form-item label="下次年检时间" prop="nextFixDate">
          <el-date-picker
            clearable
            v-model="form.nextFixDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择下次年检时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="年度审验状态" prop="checkState">
          <el-input
            v-model="form.checkState"
            placeholder="请输入年度审验状态"
          />
        </el-form-item>
        <el-form-item label="发票打印设备序列号" prop="feePrintId">
          <el-input
            v-model="form.feePrintId"
            placeholder="请输入发票打印设备序列号"
          />
        </el-form-item>
        <el-form-item label="卫星定位装置品牌" prop="gpsBrand">
          <el-input
            v-model="form.gpsBrand"
            placeholder="请输入卫星定位装置品牌"
          />
        </el-form-item>
        <el-form-item label="卫星型号" prop="gpsModel">
          <el-input v-model="form.gpsModel" placeholder="请输入卫星型号" />
        </el-form-item>
        <el-form-item label="卫星定位设备安装日期" prop="gpsInstallDate">
          <el-date-picker
            clearable
            v-model="form.gpsInstallDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择卫星定位设备安装日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报备日期" prop="registerDate">
          <el-date-picker
            clearable
            v-model="form.registerDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择报备日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="状态：0:有效，1：失效" prop="state">
          <el-input
            v-model="form.state"
            placeholder="请输入状态：0:有效，1：失效"
          />
        </el-form-item>
        <el-form-item label="终端Id" prop="tid">
          <el-input v-model="form.tid" placeholder="请输入终端Id" />
        </el-form-item>
        <el-form-item label="轨迹ID" prop="trid">
          <el-input v-model="form.trid" placeholder="请输入轨迹ID" />
        </el-form-item>
        <el-form-item label="轨迹名称" prop="trname">
          <el-input v-model="form.trname" placeholder="请输入轨迹名称" />
        </el-form-item>
        <el-form-item label="创建时间" prop="gmtCreate">
          <el-date-picker
            clearable
            v-model="form.gmtCreate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择创建时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="修改时间" prop="gmtModified">
          <el-date-picker
            clearable
            v-model="form.gmtModified"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择修改时间"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <el-form-item label="驳回原因" prop="causeOfRejection">
        <el-input
          v-model="form.causeOfRejection"
          placeholder="请输入驳回原因"
        />
      </el-form-item>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">通过</el-button>
        <el-button @click="cancel">驳回</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listCar, getCar, updateCar } from "@/api/platform/car";

export default {
  name: "Car",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      carList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        address: null,
        vehicleNo: null,
        plateColor: null,
        seats: null,
        brand: null,
        model: null,
        vehicleType: null,
        ownerName: null,
        vehicleColor: null,
        engineId: null,
        vin: null,
        certifyDateA: null,
        fueType: null,
        engineDisplace: null,
        transAgency: null,
        transArea: null,
        transDateStart: null,
        transDateEnd: null,
        certifyDateB: null,
        fixState: null,
        nextFixDate: null,
        checkState: null,
        feePrintId: null,
        gpsBrand: null,
        gpsModel: null,
        gpsInstallDate: null,
        registerDate: null,
        commercialType: null,
        fareType: null,
        state: null,
        tid: null,
        trid: null,
        trname: null,
        gmtCreate: null,
        gmtModified: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listCar(this.queryParams).then((response) => {
        this.carList = response.rows;
        this.loading = false;
      });
      listCar().then((res) => {
        this.carList = res;
      });
    },
    // 审核驳回按钮
    cancel() {
      this.form.state = 2;
      reviewAndReject(this.form).then((res) => {
        console.log(res);
      });
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        address: null,
        vehicleNo: null,
        plateColor: null,
        seats: null,
        brand: null,
        model: null,
        vehicleType: null,
        ownerName: null,
        vehicleColor: null,
        engineId: null,
        vin: null,
        certifyDateA: null,
        fueType: null,
        engineDisplace: null,
        transAgency: null,
        transArea: null,
        transDateStart: null,
        transDateEnd: null,
        certifyDateB: null,
        fixState: null,
        nextFixDate: null,
        checkState: null,
        feePrintId: null,
        gpsBrand: null,
        gpsModel: null,
        gpsInstallDate: null,
        registerDate: null,
        commercialType: null,
        fareType: null,
        state: null,
        tid: null,
        trid: null,
        trname: null,
        gmtCreate: null,
        gmtModified: null,
      };
      this.resetForm("form");
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 根据id查看详细信息的按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = 1584359540577861633;
      getCar(id).then((response) => {
        this.open = true;
        this.form = response.data;
        console.log(response.data);
        this.title = "查看详情【审核】";
      });
      getCar(id).then((res) => {
        this.open = true;
        this.form = res;
        console.log(res);

        console.log(this.form);
      });
    },
    /** 审核通过按钮 */
    submitForm() {
      this.form.state = 2;
      reviewAndReject(this.form).then((res) => {
        console.log(res);
      });
      this.open = false;
      this.reset();
    },
  },
};
</script>
